package com.assets.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.assets.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/3/18.
 */

public class Repairs_Adapter extends BaseAdapter {
    private List<Map<String, Object>> data;
    private LayoutInflater layoutInflater;
    private Context context;
    public Repairs_Adapter(Context context, List<Map<String, Object>> data) {
        //传入的data，就是我们要在listview中显示的信息
        this.context = context;
        this.data = data;
        this.layoutInflater = LayoutInflater.from(context);
    }
    public class Info {
        public TextView repairs_odd;//单号
        public TextView repairs_section;//部门
        public TextView repairs_state;//状态
        public TextView repairs_date;//日期
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.size();
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
     Info info = new Info();
        convertView = layoutInflater.inflate(R.layout.repairs_adapter, null);
        info.repairs_date = (TextView) convertView.findViewById(R.id.repairs_date);
        info.repairs_odd = (TextView) convertView.findViewById(R.id.repairs_odd);
        info.repairs_section = (TextView) convertView.findViewById(R.id.repairs_section);
        info.repairs_state = (TextView) convertView.findViewById(R.id.repairs_state);
        //设置数据
        info.repairs_date.setText((String) data.get(position).get(
                "repairs_date"));
        info.repairs_odd.setText((String) data.get(position).get(
                "repairs_odd"));
        info.repairs_section.setText((String) data.get(position)
                .get("repairs_section"));
        info.repairs_state.setText((String) data.get(position)
                .get("repairs_state"));
        return convertView;

    }
}
